import type { ConsultType } from "@/enums";
import type { ConsultIllness, PartialConsult } from "@/types/consult";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useConsultStore = defineStore('cp-consult', () => {
    const consult = ref<PartialConsult>({})
    // 设置问诊类型
    const setType = (type: ConsultType) => (consult.value.type = type)
    // 设置急速问诊类型 0 普通  1 三甲
    const setIllnessType = (type: 0 | 1) => (consult.value.illnessType = type)
    // 科室类型
    const setDepType = (id: string) => (consult.value.depId = id)
    // 收集病情描述
    const setIllness = (illness: ConsultIllness) => {
        consult.value.illnessDesc = illness.illnessDesc
        consult.value.illnessTime = illness.illnessTime
        consult.value.consultFlag = illness.consultFlag
        consult.value.pictures = illness.pictures
    }
    // 记录患者id
    const setPatientId = (id: string) => (consult.value.patientId = id)
    // 记录优惠券
    const setCouponId = (id: string) => {
        consult.value.couponId = id
    }
    // 清除数据
    const clear = () => {
        consult.value = {}
    }
    return {
        consult,
        setType,
        setIllnessType,
        setDepType,
        setIllness,
        setPatientId,
        setCouponId,
        clear
    }
},
{
    persist: true
})